<?php
/**
 * 在线订药
 */
require 'conn.php';
session_start();
$username=$_SESSION['username'];
$sql="select UserId from userinfo where UserName='$username'";
$query=mysqli_query($conn,$sql);
$userid=mysqli_fetch_assoc($query);
$userid=implode(',',$userid);

if (isset($username)){
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>在线订药</title>
</head>
<body>
<div style="width: 500px;margin: auto;">
    <h1>在线订药</h1>
    <hr>
    <form action="order2.php" method="post" enctype="multipart/form-data">
    <table style="margin: auto;">
        <input type="text" name="UserId" value="<?php echo $userid?>" hidden>
        <input type="text" name="State" value="1" hidden>
        <input type="text" name="AddTime" id="today" hidden>
        <script type="text/javascript">
            function today(){//构建方法
                var today=new Date();//new 出当前时间
                var h=today.getFullYear();//获取年
                var m=today.getMonth()+1;//获取月
                var d=today.getDate();//获取日
                var H = today.getHours();//获取时
                var M = today.getMinutes();//获取分
                var S = today.getSeconds();//获取秒
                return h+"-"+m+"-"+d+" "+H+":"+M+":"+S; //返回 年-月-日 时:分:秒
            }
            document.getElementById("today").value = today();
        </script>
        <tr>
            <td>药名</td>
            <td><input type="text" name="MedicineName"></td>
        </tr>
        <tr>
            <td>收货人姓名</td>
            <td><input type="text" name="RealName"></td>
        </tr>
        <tr>
            <td>收货人电话</td>
            <td><input type="text" name="Mobile"></td>
        </tr>
        <tr>
            <td>收货地址</td>
            <td><input type="text" name="Address"></td>
        </tr>
        <tr>
            <td>配送方式</td>
            <td><input type="radio" name="SendType" value="0">商家配送<input type="radio" name="SendType" value="1">自提</td>
        </tr>
        <tr>
            <td>备注</td>
            <td><textarea name="Remark"></textarea></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" value="订购"></td>
        </tr>
    </table>
    </form>
</div>
</body>
</html>
<?php
}else{
echo "<script>alert('请先登录！');window.location.href='Login.php';</script>";
}